package com.lexandro.lemuplayerbot.service;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.lexandro.lemuplayerbot.ui.PlayerUI;

@Component("lemubotService")
public class PlayerUILemubotService implements LemuPlayerBotService {
	private static final Logger LOGGER = Logger.getLogger(PlayerUILemubotService.class);
	//
	
	@Autowired
	@Qualifier("playerUI")
	private PlayerUI playerUI;

	@Value("${playerUI.userName}")
	private String playerUser;

	@Value("${playerUI.password}")
	private String playerPassword;

	public void start() {
		playerUI.login(playerUser, playerPassword);
		playerUI.refreshSession();
		long counter = 0;

		while (true) {
			try {
				LOGGER.info("Minutes:" + counter);
				//
				Thread.sleep(60 * 1000);
				//
				playerUI.refreshSession();
				//
				counter++;
				//
			} catch (InterruptedException e) {
				e.printStackTrace();
				break;
			}

		}

	}

}
